home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-07-29 | 4.6 KB | 333 lines | [TEXT/MPS ] |
- *******************************************************************
- *
- * SanityInit -- a temporary init to load DAs and Inits from a
- * common folder when you're juggling multiple
- * System folders
- *
- * by David A. Lyons, 28-Jul-90
- *
- * Put SanityInit in all your *:System folders, and put all the
- * NDAs, CDAs, PIFs, and TIFs you want to load in *:Common.
- *
- *******************************************************************
- *
- * 28-Jul-90 DAL --> v1.0
- * Initial coding (borrowing code for directory scan and
- * InitialLoad from Nifty List 3.1p source)
- *
- *
- *******************************************************************
-
- include 'm16.memory'
- include 'm16.loader'
- include 'm16.util'
- include 'm16.gsos'
- include 'm16.desk'
-
- tPIF equ $b6
- tTIF equ $b7
- tNDA equ $b8
- tCDA equ $b9
-
- cr equ 13
-
- Sanity PROC
- Case off
-
- brl @go
- dc.b cr
- dc.b 'Sanity Init 1.0 by David A. Lyons 28-Jul-90',cr
- dc.b ' P.O. Box 875, Cupertino CA 95015',cr
- dc.b ' GEnie: DAVE.LYONS',cr
- dc.b ' America Online: Dave Lyons',cr
- dc.b cr
-
- @go phb
- phk
- plb
- php
- rep #$30
-
- jsr doScan
-
- plp
- plb
- rtl
-
- doScan jsr SetPrefix0
- jsr LoadThings
- jsr FixPrefix0
- rts
-
- *
- * Set Prefix 0 to the directory
- *
- SetPrefix0 jsr CheckP16
- bcs @x
- _GetPrefixGS origPrefix
- _SetPrefixGS newPrefix
- @x rts
-
- *
- * Put prefix 0 back how it was before SetPrefix0
- *
- FixPrefix0 jsr CheckP16
- bcs @x
- _SetPrefixGS restorePrefix
- @x rts
-
- origPrefix dc.w 2
- dc.w 0
- dc.l tempPrefix
- restorePrefix dc.w 2
- dc.w 0
- dc.l tempPrefix+2
- newPrefix dc.w 2
- dc.w 0
- dc.l CommonPath
-
- tempPrefix dc.w 67
- ds 65
-
- CommonPath dc.w 8
- dc.b '*:Common'
-
- *
- * Load Things from the *:Common directory (prefix 0 is already here)
- *
- LoadThings _OpenGS OpenTheDir
- bcs ltDone
- lda dirRef
- sta dirRef2
- sta dirRef3
-
- GetNextName _GetDirEntryGS GetDirEnt
- bcs ltClose
- lda entAux
- bmi @inactive
- lda entType
- jsr Load1Thing
- @inactive bra GetNextName
-
- ltClose _CloseGS CloseTheDir
- ltDone rts
-
- OpenTheDir dc.w 3
- dirRef dc.w 0
- dc.l ZeroColon
- dc.w $0001 ;read only
- ZeroColon dc.b 2,0,'0:'
-
- CloseTheDir dc.w 1
- dirRef3 dc.w 0
-
- GetDirEnt dc.w 13
- dirRef2 dc.w 0
- dc.w 0,1,1 ;flags, base, displacement
- dc.l fileNameBuff
- dc.w 0 ;entry num
- entType dc.w 0 ;filetype
- dc.l 0 ;eof
- dc.l 0 ;blocks
- dc.l 0,0,0,0 ;create/mod date/time
- dc.w 0 ;access
- entAux dc.l 0 ;auxtype
-
- fileNameBuff
- dc.w 36
- ds 34
- *
- * Load1Thing--load the file in fileNameBuff (filetype in A)
- *
- Load1Thing sta typTable
- ldx #IDTable-typTable
- @srch dex
- dex
- cmp typTable,x
- bne @srch
- stx foundX
-
- lda IDTable,x
- tay
- beq @ltDone ;id=0 means don't load it
- jsr LoadIt
- bcs @ltDone
-
- ldx foundX
- lda GoTable,x
- dec a
- pha
- lda theID
- ldx theAddr+2
- ldy theAddr
- @ltDone rts
-
- typTable dc.w $7777,tCDA,tNDA,tPIF,tTIF
- IDTable dc.w $0000,$5000,$5000,$A000,$A000
- GoTable dc.w GoXXX,GoCDA,GoNDA,GoPIF,GoTIF
- foundX dc.w 0
- *
- * GoXXX ("Go" routines called with A=ID, XY=address)
- *
- GoXXX rts
- *
- * GoCDA
- *
- GoCDA pha
- pha
- phx
- phy
- _FindHandle
- _InstallCDA
- rts
- *
- * GoNDA
- *
- GoNDA pha
- pha
- phx
- phy
- _FindHandle
- _InstallNDA
- rts
- *
- * GoPIF
- *
- GoPIF jsr SetupStk ;screws B
-
- pea 0 ;space for "unload-me" flag
- jsl JmpTheAddr
- rep #$30
- pla
- sta >theResult
-
- jsr RestoreStk
- lda theResult
- lsr a
- bcc @keep
- lda theID
- jsr ShutdownA
- @keep rts
-
- theResult dc.w 0
- *
- * GoTIF
- *
- GoTIF jsr SetupStk ;screws B
- jsr JmpTheAddr
- jsr RestoreStk
- jsr ShutdownA
- rts
- *
- * JmpTheAddr -- transfer control to theAddr, with A=theID, XY=0
- *
- JmpTheAddr lda >theAddr+2
- sep #$20
- pha
- rep #$20
- lda >theAddr
- dec a
- pha
- lda >theID
- ldx #0
- txy
- rtl
- *
- * ShutDownA -- UserShutDown ID=A
- *
- ShutdownA pha ;space for new ID
- lda theID
- pha
- pea 0
- _UserShutDown
- pla
- rts
- *
- * SetupStk--switch to the thing's own stack/dp, if any
- *
- SetupStk plx
-
- tdc
- sta myDP
- tsc
- sta myStack
-
- lda theDP
- beq @noDP
- tcd
- clc
- adc theDPSize
- dec a
- tcs
- @noDP
- pea $ffff
- plb
- plb
-
- phx
- rts
- *
- * RestoreStk--go back to using my own stack/dp
- *
- RestoreStk rep #$30
- plx
- phk
- plb
- lda myStack
- tcs
- lda myDP
- tcd
- phx
- rts
-
- myStack dc.w 0
- myDP dc.w 0
-
- *
- * LoadIt--filename in fileNameBuff, ID in Y carry/A=err,
- * theID, theAddr, theDP, theDPSize
- *
- LoadIt pha
- pha
- pha
- pha
- pha
- phy ;mem ID in Y
- pushlong #FileNameBuff+2
- pea 1 ;no special memory
- pea 1 ;name is a GS/OS string
- _InitialLoad2
- plx ;memID
- stx theID
- plx ;address low
- stx theAddr
- plx ;address high
- stx theAddr+2
- plx ;direct-page location
- stx theDP
- plx ;direct-page size
- stx theDPSize
- rts
-
- theID dc.w 0
- theAddr dc.l 0
- theDP dc.w 0
- theDPSize dc.w 0
-
- *
- * CheckP16 -- return SEC if 16-bit OS is not available
- *
- CheckP16 lda $e100ba
- bne noP16z
- lda $e100bc
- and #$00ff
- cmp #$01
- bne noP16z
- clc
- rts
- noP16z sec
- rts
-
- endp
- end
-